﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MassMailing.WPF.Content
{
    /// <summary>
    /// A receipient of the message trying to be sent.
    /// </summary>
    [Serializable]
    public sealed class Recipient
    {
        /// <summary>
        /// The name of the reciepient to include in the email.
        /// </summary>
        public String Name { get; set; }

        /// <summary>
        /// The email address of the reciepient.
        /// </summary>
        public String EmailAddress { get; set; }

        #region Methods

        /// <summary>
        /// Returns a string that represents a recipient in string format.
        /// </summary>
        /// <returns>A string representing the recipient.</returns>
        public override string ToString()
        {
            if (string.IsNullOrWhiteSpace(Name) && string.IsNullOrWhiteSpace(EmailAddress))
            {
                return string.Empty;
            }

            if (string.IsNullOrWhiteSpace(Name))
            {
                return EmailAddress;
            }

            return string.Format("{0} <{1}>", Name, EmailAddress);
        }

        #endregion
    }
}
